<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
  
        <el-form-item label="登记日期" prop="locationName">
            <el-date-picker
                size="mini"
                v-model="queryParams.beginDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择周一"
                :picker-options="pickerOptions">
            </el-date-picker>
        </el-form-item>
        <el-form-item label="班级名称" prop="locationName">
            <el-input v-model="queryParams.className" size="mini" placeholder="你输入班级名称"></el-input>
        </el-form-item>
        <el-form-item label="班主任" prop="locationName">
            <el-input v-model="queryParams.classTeacherName" size="mini" placeholder="你输入班主任姓名"></el-input>
        </el-form-item>
        
  
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
  
      <el-row :gutter="10" class="mb8">

        
        <!-- <el-col :span="1.5">
          <el-button
            type="danger"
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['basedata:bclass:remove']"
          >删除</el-button>
        </el-col> -->
  
      </el-row>
  
      <el-table v-loading="loading" :data="bclassList">
        <el-table-column label="班级名称" align="center" width="220" prop="className" :show-overflow-tooltip="true" />
        <el-table-column label="班主任" align="center" width="220" prop="classTeacherName" :show-overflow-tooltip="true" />
        <el-table-column label="班级部门" align="center" prop="classDept" :show-overflow-tooltip="true" >
          <template slot-scope="scope">
            <div v-if="scope.row.classDept==1">技工</div>
            <div v-if="scope.row.classDept==2">BCSP</div>
            <div v-if="scope.row.classDept==3">实训</div>
          </template>
        </el-table-column>
        <el-table-column label="全部数量" align="center" prop="allCount" :show-overflow-tooltip="true" >
          <template slot-scope="scope">
            <el-link type="primary" @click="openWindow(scope.row,'99')">{{scope.row.allCount}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="提交数量" align="center" prop="doneCount" :show-overflow-tooltip="true" >
          <template slot-scope="scope">
            <el-link  type="success" @click="openWindow(scope.row,'1')">{{scope.row.doneCount}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="未提交数量" align="center" prop="undoneCount" :show-overflow-tooltip="true" >
          <template slot-scope="scope">
            <el-link  type="danger" @click="openWindow(scope.row,'0')">{{scope.row.undoneCount}}</el-link>
          </template>
        </el-table-column>
      </el-table>
  
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
  
      <!-- 添加或修改参数配置对话框 -->
      <el-dialog :title="title" :visible.sync="open" v-if="open" width="60%">
        <el-tabs type="border-card">
          <el-tab-pane>
            <span slot="label"><i class="el-icon-date"></i> 每日计划</span>
            <dayList  :classId="selectRow.id" :done="isDone"></dayList>
          </el-tab-pane>
          <el-tab-pane>
            <span slot="label"><i class="el-icon-edit-outline"></i>考核/作业</span>
            <daywork :classId="selectRow.id" :done="isDone"></daywork>
          </el-tab-pane>
        </el-tabs>
        
      </el-dialog>
    </div>
  </template>
  
  <script>
import {pageList} from "@/api/evaluation/report"
import dayList from "@/views/evaluation/day/index"
import daywork from "@/views/evaluation/daywork/index"

  export default {
    name: "BClass",
    components: {
      dayList,daywork
    },
    data() {
      return {
        isDone:null,
        selectRow:{},
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 总条数
        total: 0,
        stuCount: 0,
        // 字典表格数据
        bclassList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 班主任
        userOptions: [],
        // 状态数据字典
        statusOptions: [],
        // 班级所属部门
        classDeptOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10
        },
        // 表单参数
        formData: {
            id:null,
            classMeeting: null
        },
        pickerOptions: {
            // 自定义方法来判断日期是否可选
            onPick: ({ selection }) => {
            // 如果已经选中了一个日期，则需要判断它是否为周一
            if (selection.size > 0) {
                const selectedDay = Array.from(selection)[0];
                const isMonday = selectedDay.getDay() === 1; // 0代表周日，1代表周一
                if (!isMonday) {
                this.$message.error('只能选择周一');
                // 重置选中的日期
                this.$refs.picker.handleClearSelection();
                }
            }
            },
            // 自定义方法来判断某个日期是否可选
            disabledDate: (time) => {
            // 只有周一（即星期一）可选
            return time.getDay() !== 1;
            }
        }

      };
    },
    created() {
      this.getList();
    },
    methods: {
        submitForm(){
            updateInterview(this.formData).then(resp=>{
                if(resp.code==200){
                    this.msgSuccess("提交成功")
                    this.getList()
                    this.open=false
                }
            })
        },
        openWindow(row,type){
            this.open=true
            this.selectRow = row
            console.log(this.selectRow)
            this.isDone = type
        },
      execute(row){
        executeTask({
          jobName: row.jobName,
          jobGroupName: row.jobGroupName
        }).then(resp=>{
          this.msgSuccess("操作成功")
        })
      },
      /** 查询班级列表 */
      getList() {
        this.loading = true;
        this.bclassList=[]
        pageList(this.queryParams).then(response => {
            this.bclassList = response.data.list;
            this.total = response.data.total;
            this.loading = false;
          }
        );
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
            id:null,
            locationName:null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        if(this.queryParams.locationName){
            this.queryParams.locationPid=null
        }else{
            this.queryParams.locationPid=0
        }
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.dateRange = [];
        this.resetForm("queryForm");

        this.handleQuery();
      }
    }
  };
  </script>
  